package com.zxp.server.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zxp.server.config.Result;
import com.zxp.server.dto.BlogTypeInfo;
import com.zxp.server.service.IBlogTypeService;
import com.zxp.server.vo.BlogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 朱小皮
 * @since 2022-05-14
 */
@Api(value = "博客分类管理", tags = "博客分类管理")
@RestController
@RequestMapping("/blogType")
public class BlogTypeController {
    @Autowired
    private IBlogTypeService blogTypeService;

    @ApiOperation(value = "获取博客分类")
    @GetMapping("/getTypeList")
    public Result getTypeList() {

        QueryWrapper<BlogType> wrapper = new QueryWrapper<>();
        List<BlogType> blogTypes = blogTypeService.getBaseMapper().selectList(wrapper);
        return Result.success("获取分类成功",blogTypes);
    }

    @ApiOperation(value = "获取分类下博客数量")
    @GetMapping("/getTypeOrBlogList")
    public Result getTypeOrBlogList() {
        List<BlogTypeInfo> blogTypeInfo = blogTypeService.getBlogTypeInfo();
        return Result.success("获取分类成功",blogTypeInfo);
    }
}

